﻿using MarketMS;
using Model;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;

namespace BLL
{
    public class AdminService
    {
        static SqlServerDBHelper db = null;
        public AdminService()
        {
            db = new SqlServerDBHelper();
        }
        public AdminInfo Login(string name, string pass)
        {
            string sql = string.Format(@"select * from AdminInfo 
where AdminName='{0}' and AdminPass='{1}'", name, pass);
            AdminInfo admin = null;
            DbDataReader dr = db.GetReader(sql);
            if (dr.Read())//判断是否查询到数据
            {
                admin = new AdminInfo();
                admin.AdminID = Convert.ToInt32(dr["AdminID"]);
                admin.AdminName = dr["AdminName"].ToString();
                admin.AdminPass = dr["AdminPass"].ToString();
            }
            dr.Close();
            db.Close();

            return admin;
        }
    }
}
